package main

import (
	"01-crawler-project/03_distributed/engine"
	"01-crawler-project/03_distributed/persist"
	"01-crawler-project/03_distributed/scheduler"
	"01-crawler-project/03_distributed/zhenai/parse"
	"net/http"
)

var client *goes.Client

var host = "http://localhost:9200/"

var (
	ES_HOST = "localhost"
	ES_PORT = "9200"
)

//初始化
func init() {

	var err error

	client = goes.NewClient(ES_HOST, ES_PORT)

	if err != nil {

		print(err)
	}

}

func main() {

	request, _ := http.NewRequest(http.MethodGet, "http://www.zhenai.com/zhenghun", nil)

	concurrentEngine := engine.ConcurrentEngine{
		Scheduler:   &scheduler.QueuedScheduler{},
		WorkerCount: 100,
		ItemChan:    persist.ItemServer(),
	}

	concurrentEngine.Run(engine.Request{
		HttpRequest: request,
		ParserFunc:  parser.ParserCityList,
	})
}
